package servlets;
/**
 * 第一个Servlet，输出当前系统时间
 */
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns="/first.view")
public class FirstServlet extends HttpServlet{
	
	private static final long serialVersionUID = 1L;
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		        throws ServletException, IOException
		    {
		 	resp.setContentType("text/html;charset=UTF-8");
			PrintWriter out = resp.getWriter();
			out.println("<html>");
			out.println("<head><title>FirstServlet</title></head>");
			out.println("<body>");
			out.println(" Hello Servlet <br>");
			out.println("当前时间："+new Date());
			out.println("</body>");
			out.println("</html>");
			out.close();
		    
		    }
	 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		        throws ServletException, IOException {
		 doGet(req, resp);
		    }
}
